import { createStore } from 'vuex';

export default createStore({
  state: {
    traObjects: [], //轨迹数据
  },
  getters: {},
  mutations: {
    setTraObjects(state, data) {
      //设置数据
      state.traObjects = data;
    },
    updateTraObjects(state, data) {
      //添加数据
      state.traObjects.push(data);
    },
    deleteTraObjects(state, name) {
      if (state.traObjects.some((item) => item['fileName'] === name)) {
        //判断是否存在同名的filename
        state.traObjects = state.traObjects.filter(
          (item) => item['fileName'] !== name
        ); //过滤数据
      }
    },
  },
  actions: {},
  modules: {},
});
